package com.yt.system.controller;

import com.alibaba.fastjson.JSON;
import com.yt.system.domain.Resource;
import com.yt.system.service.ResourceService;
import com.yt.system.vo.UserApplyResourceVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/resource")
public class ResourceController {

    @Autowired
    private ResourceService resourceService;

    @ApiOperation(value = "根据资源类型查找资源；参数：type；其中1代表会议室，2代表音响，3代表麦克风，4代表黑板，5代表资源a")
    @PostMapping("/selectResourceByType")
    public List<Resource> selectResourceByType(Integer type){
        System.out.println("--------type------"+type);
        List<Resource> resources = resourceService.selectResourceByType(type);
        return resources;
    }

    @ApiOperation("查询所有资源")
    @RequestMapping(value = "findAllResouce",method = RequestMethod.POST)
    public List<Resource> findAllResouce(){
        List<Resource> list = resourceService.findAllResource();
        return list;
    }

    /**
     * 查看资源管理记录（已被申请：flag=1 和历史申请：flag=3，申请时间到默认归还修改标志位）
     */
    @ApiOperation(value = "查看资源管理记录；参数：flag；已被申请：flag=1 和历史申请：flag=3，申请时间到默认归还修改标志位")
    @PostMapping("/selectByFlag")
    public List<UserApplyResourceVO> selectByFlag(Integer flag){
        List<UserApplyResourceVO> userApplyResourceVOS = resourceService.selectByFlag(flag);
        return userApplyResourceVOS;
    }

    /**
     * 管理员查看待审核资源
     */

}
